package com.ohos.carbon.slice;

import com.ohos.carbon.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;

import java.util.Map;

import static com.ohos.carbon.slice.MainAbilitySlice.pf;

public class AnchorsSlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_anchors);
        initView();

        MainAbilitySlice.all = (Map<String, Integer>) pf.getAll();
        if (MainAbilitySlice.all.size() != 0) {
            if (MainAbilitySlice.all.containsKey("Anchors")) {
                for (Map.Entry<String, Integer> entry : MainAbilitySlice.all.entrySet()) {
                    if (entry.getKey().equals("Anchors")) {
                        int integer = entry.getValue();
                        integer++;
                        pf.putInt("Anchors", integer);
                        pf.flushSync();
                    }
                }
            } else {
                pf.putInt("Anchors", 1);
                pf.flushSync();
            }
        } else {
            pf.putInt("Anchors", 1);
            pf.flushSync();
        }

    }

    private void initView() {

    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
